<template>
  <div>
    <!-- 顶栏 -->
    <van-nav-bar title="我的关注" left-arrow @click-left="$router.back()" />
  
  <!-- 遍历关注列表 -->
    <div class="list" v-for="item in myFollowsList" :key="item.id">
    <div class="box">
      <img src="../assets/logo.png" alt="" />
      <div class="center">
        <!-- 关注的作者名 -->
        <p>{{item.nickname}}</p>
        <!-- 关注的时间 -->
        <span>{{item.create_date|dateFilter}}</span>
      </div>
      <span @click="cancel(item.id)">取消关注</span>
    </div>
  </div>
  </div>
</template>

<script>
import { followList, unFollow } from "../api/user";
export default {
  data() {
    return {
        // 定义一个空数组
        myFollowsList:[]
    };
  },
    //一点开就显示关注列表
  created(){
    this.loadFollows()
  },
  methods: {
    loadFollows(){
        followList().then(res=>{
            // console.log(res.data.data);
            this.myFollowsList=res.data.data
        })
    },
    cancel(id){
        unFollow(id).then(res=>{
            if(res.data.message==='取消关注成功'){
                this.$toast(res.data.message)
                this.loadFollows()
            }else{
                this.$toast(rss.data.message)
            }
        })
    }
  },
};
</script>

<style lang="less" scoped>
.list {
  .box {
    display: flex;
    padding: 25px 10px;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #ccc;
    > img {
      display: block;
      width: 50/360 * 100vw;
      height: 50/360 * 100vw;
      border-radius: 50%;
      padding: 0 10px;
    }
    > .center {
      flex: 1;
      > p {
        line-height: 30px;
        font-size: 14px;
      }
      > span {
        font-size: 12px;
        color: #999;
      }
    }
    > span {
      height: 30px;
      background-color: #eee;
      font-size: 13px;
      border-radius: 30px;
      line-height: 30px;
      padding: 0px 15px;
    }
  }
}
</style>